<!DOCTYPE HTML>
<html>
<head>
    {include file="common_header"}
    <title>修改栏目</title>
    <style>
        .progress{
            width: 200px;
        }
        .progress-bar{
            height: 40px;
        }
        .fileinput-remove{
            display: none !important;
        }
    </style>
</head>
<body>
<div class="page-container">
    <form class="form form-horizontal"  method="post" enctype="multipart/form-data" action="{:url('edit',array('type'=>'goods'))}">
        <input type="hidden" name="id" value="{$data['id']}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>商品名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{$data['goods_name']}" placeholder="请输商品目名称" id="name"  name="goods_name" datatype="*" nullmsg="请输商品目名称">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">商品主图：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="file" class="input-text" value="" placeholder="" id="articletitle2" name="coverFile">
            </div>
            {if condition="$data['goods_image']"}
                已上传：<a href="javascript:void(0);"  onclick="previewPictures('__UPLOADS__'+'{$data.goods_image}')" style="color: red;text-decoration: none;">预览</a>
            {/if}
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>商品所属分类：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
				<select name="classify_id" class="select" datatype="*" nullmsg="请选择菜单" placeholder="请选择分类">
					<option value="" selected disabled>请选择栏目</option>
                    {volist name="classlist" id="v"}
                        <option value="{$v['id']}"  {if condition="$v['father_id'] eq 0"} disabled{/if} {if condition="$data['classify_id'] eq  $v['id']"}selected{/if}>{$v['classify_name']}</option>
                    {/volist}
				</select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>商品原价：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{$data['goods_price']}" placeholder="请填写商品价格" id="price"  name="goods_price" datatype="*" nullmsg="请填写商品价格">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>商品优惠价：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{$data['goods_discount']}" placeholder="请填写商品价格" id="discount"  name="goods_discount" datatype="*" nullmsg="请填写商品价格">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>商品库存：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{$data['goods_num']}" placeholder="请填写商品库存" id="num"  name="goods_num" datatype="*" nullmsg="请填写商品库存">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>商品单位：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="{$data['goods_unit']}" placeholder="请填写商品库存"   name="goods_unit" datatype="*" nullmsg="请填写商品单位">
            </div>
        </div>
                <input id="imgs" type="hidden"  value="{$data['good_urlimg']}" class="input-text" name="good_urlimg">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">商品详情图片：</label>
            <div class="formControls col-xs-8 col-sm-9"  >
                <input id="upfile" type="file"  multiple class="file" data-overwrite-initial="false" data-min-file-count="1"  name="images">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">商品描述：</label>
            <div class="formControls col-xs-8 col-sm-9" >
                <textarea name="goods_content" cols="" rows="" class="textarea"  placeholder="说点什么...最少输入10个字符" datatype="*"  nullmsg="请填写商品描述" >{$data['goods_content']}</textarea>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</div>
<!--_footer 作为公共模版分离出去-->
{include file="common_footer"}
<!--/_footer 作为公共模版分离出去-->
</body>
<link href="__ACSS__bootstrap.css" rel="stylesheet">
<link href="__ACSS__fileinput.min.css" media="all" rel="stylesheet" type="text/css" />
<script src="__AJS__fileinput.js" type="text/javascript"></script>
<script src="__AJS__bootstrap.js" type="text/javascript"></script>
<script src="__AJS__zh.js" type="text/javascript"></script>
<script>
    var path={$path};
    var config={$config};
    initFileInput("upfile", "{:Url('goods/uploadImg')}");
    function initFileInput(ctrlName, uploadUrl){
        var control = $('#'+ctrlName);
        control.fileinput({
            language: 'zh', //设置语言
            uploadUrl:uploadUrl,    //上传的地址
            allowedFileExtensions:['jpg','png'],    //接收的文件后缀
            showUpload:true,    //是否显示上传按钮
            showCaption:false,    //是否显示标题
            maxFileSize: 1000,    //图片最大尺寸kb 为0不限制
            maxFilesNum: 6,        //最多上传图片
            overwriteInitial: false,//不覆盖已上传的图片
            browseClass: "btn btn-info", //按钮样式
            dropZoneEnabled: true,//是否显示拖拽区域
            previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
            msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
            initialPreviewAsData: true,
            initialPreview: path,
            layoutTemplates :{
                actionUpload:''
            },
            initialPreviewConfig:config
        });
    }
    /**
     *删除数据后更新自定义数组
     * 更新input中的值
     */
    var List = new Array();//定义一个全局变量去接受文件名和id
    for (var i = 0; i < path.length; i++) {
        List.push({ FileName: path[i], KeyID:i});
    }
    $('#upfile').on('filepredelete', function(event, key) {
        var urls="";
        for (var i = 0; i < List.length; i++) {
            if (List[i].FileName== key) {
                List.splice(i,1);
            }
        }
        for (var j = 0; j < List.length; j++){
            urls+=List[j].FileName+',';
        }
        $("#imgs").val(" ");
        $("#imgs").val(urls);
    });
    /**
     *上传完路径之后插入自定的数组中
     * 更新input中的值
     */
    $("#upfile").on("fileuploaded", function(event, data, previewId, index) {
        var datas = data.response.url;  //文件上传成功返回的文件名，可返回自定义文件名
        List.push({ FileName: datas, KeyID: previewId });
        var url="";
        var imgs=$("#imgs").val();
        if(!imgs){
            url=datas;
        }else{
            url=imgs+','+datas;
        }
        $("#imgs").val(" ");
        $("#imgs").val(url);
    })
</script>
</html>